<?php


class pageActions extends sfActions
{

	public function executeLogin($request)
	{
		$this->setLayout('login');
		$this->redirectIf($this->getUser()->isAuthenticated(), '@homepage');

		$loginForm = new LoginForm();

		
		if ($this->getRequest()->isMethod('post'))
		{
			$login_form = $this->getRequest()->getParameter('login');
                        
			$loginForm->bind($login_form);

			if ($loginForm->isValid())
			{
                            
                            $this->getUser()->signIn($loginForm['username']->getValue('username'));
                            $this->redirect('@homepage');
			}
		} else {
			// Save original requested uri in form
			//  $loginForm->setDefault('referrer', sfContext::getInstance()->getRequest()->getUri());
		}

		$this->loginForm = $loginForm;
	}

	/**
	 * Executes Logout
	 */
	public function executeLogout()
	{
		$this->getUser()->signOut();

		$this->redirect('page/login');
	}


	

	

	public function executeIndex()
	{
	}

	
}
